"""
3 12
2 3
3 2
4 1
"""


def firstInput():
    # m, n = map(int, input().split())
    # hashMap = {}
    # for i in range(m):
    #     temp = list(map(int, input().split()))
    #     hashMap[i] = temp
    m, n = 3, 12
    hashMap = {0: [2, 3], 1: [3, 2], 2: [4, 1]}
    return m, n, hashMap


def main():
    m, n, hashMap = firstInput()
    nums = [[2, 3], [3, 2], [4, 1]]
    minA, minB = 9999, 9999
    for i in range(m):
        curList = hashMap[i]
        minA = min(curList[0], minA)
        minB = min(curList[1], minB)
    res = [[0 for _ in range(4)] for _ in range(m)]

    flowerA = n
    nums = sorted(nums, key=lambda x: x[0])
    while flowerA > 0:
        for i in range(m):
            cur = nums[i][0]
            res[i][0] = res[i][0] + cur
            # res[i][1] = res[i][1] + 1

            flowerA -= 1
            if flowerA < 0:
                break

    flowerB = n
    nums = sorted(nums, key=lambda x: x[1])

    while flowerB > 0:
        for i in range(m):
            cur = nums[i][1]
            res[i][2] = res[i][2] + cur
            # res[i][3] = res[i][3] + 1

            flowerB -= 1
            if flowerB < 0:
                break
    print()
    print(res)






if __name__ == "__main__":
    # firstInput()
    main()
    # print(n+1)  3.3%
